LINQ/LAMBDA filter query by date [on hold]
Posted
by
inquisitive_one
on Programmers
See other posts from Programmers
or by inquisitive_one
Published on 2013-06-26T19:23:27Z
Indexed on
2013/06/26
22:29 UTC
Read the original article
Hit count: 232
I'm trying to use LINQ to SQL to retrieve earnings data for a particular date range. Currently the table is set up as follows:
Comp Eps Year Quarter
IBM .5 2012 2
IBM .65 2012 3
IBM .60 2012 4
IBM .5 2011 2
IBM .7 2013 1
IBM .8 2013 2
Except for Eps, all fields have a data type of string or char. Eps has a data type of double. Here's my code:
var myData = myTable
.Where(t => t.Comp.Equals("IBM")
&&
Convert.Int32(string.Format("{0}{1}", t.Year, t.Quarter)) <= 20131);
I get the following error when I tried that code:
Method 'System.String Format(System.String, System.Object, System.Object)' has no supported translation to SQL
How can I select all Eps that has a year & quarter less than "20132" using a lambda expression?
© Programmers or respective owner